package mahjong;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
@SuppressWarnings("serial")
public class TimeManager extends JPanel{
	
	/** Time label */
	private JLabel timeLabel;
	
	public TimeManager()
	{
		timeLabel =  new JLabel(GameTime.getTimeString(), SwingConstants.CENTER);
		
		//Initialise the timer
		GameTime.timer.addActionListener( new
				ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				timeLabel.setText(GameTime.getTimeString());
				timeLabel.repaint();
			}
		}
		);	
		
		this.add(timeLabel);
	}
	
	/**
	 * Reset the time label to the current game time
	 */
	public void resetTimeLabel()
	{
		timeLabel.setText(GameTime.getTimeString());
		timeLabel.repaint();
	}
}
